﻿using System.Linq;

namespace Utk.Nlp
{
    class Pattern : IClassificator, IGenerator
    {
         private readonly string[] _values;

         public Pattern(params string[] values)
         {
             _values = values;
         }

        public double Match(string value)
        {
            return _values.Max(_ => 1.0D / (Levenstein.Compute(value.ToUpper(), _.ToUpper()) + 1));
        }

        public string Generate()
        {
            return _values[Coin.GetRandomNumber(_values.Length)];
        }

        public static implicit operator Pattern(string value)
        {
            return new Pattern(value);
        }
    }
}